﻿<%@ Page Title="Reservas" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="reservasHechas.aspx.cs" Inherits="Restaurante.reservasHechas" %>

  


<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
         <p id="titulo"> Reservas hechas</p>
    </h2>
    <div class="contTabla">
        <asp:GridView ID="gvReservas" runat="server" CellPadding="4" 
            ForeColor="#333333" GridLines="None" Width="598px" 
            AutoGenerateColumns="False" ShowFooter="True" AllowSorting="True" 
            DataKeyNames="reserva" DataSourceID="reservas" AllowPaging="True" 
            onselectedindexchanged="gridReservas_SelectedIndexChanged">
            <AlternatingRowStyle BackColor="White" />
            <Columns>
 <asp:CommandField ShowSelectButton="True" />                <asp:BoundField DataField="reserva" HeaderText="reserva" 
                    SortExpression="reserva" InsertVisible="False" ReadOnly="True" />                
                <asp:BoundField DataField="fecha" HeaderText="fecha" 
                    SortExpression="fecha" />                
                <asp:BoundField DataField="comensales" 
                    HeaderText="comensales" SortExpression="comensales" />
                <asp:BoundField DataField="cliente" HeaderText="cliente" 
                    SortExpression="cliente" ReadOnly="True" />
                <asp:BoundField DataField="estado" HeaderText="estado" 
                    SortExpression="estado" />
            </Columns>
            <EditRowStyle BackColor="#2461BF" />
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#EFF3FB" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#F5F7FB" />
            <SortedAscendingHeaderStyle BackColor="#6D95E1" />
            <SortedDescendingCellStyle BackColor="#E9EBEF" />
            <SortedDescendingHeaderStyle BackColor="#4870BE" />
        </asp:GridView>
        <asp:SqlDataSource ID="reservas" runat="server" 
            ConnectionString="<%$ ConnectionStrings:BarCafe %>" 
            ProviderName="<%$ ConnectionStrings:BarCafe.ProviderName %>" 
            SelectCommand="SELECT r.Nro_Reserva AS reserva, r.Fecha_Reserva AS fecha, r.Cantidad_Comensales AS comensales, c.Nombre + ' ' + c.Apellido AS cliente, e.Descripcion AS estado FROM Reserva AS r INNER JOIN Cliente AS c ON c.Id_Cliente = r.Id_Cliente INNER JOIN Estado AS e ON e.Id_Estado = r.Id_Estado WHERE (e.Descripcion = 'Sin Confirmar') ORDER BY fecha" 
            DeleteCommand="DELETE FROM [Reserva] WHERE [Nro_Reserva] = @Nro_Reserva" 
            InsertCommand="INSERT INTO [Reserva] ([Fecha_Reserva], [Id_Estado], [Id_Mesa], [Id_Cliente], [Cantidad_Comensales]) VALUES (@Fecha_Reserva, @Id_Estado, @Id_Mesa, @Id_Cliente, @Cantidad_Comensales)" 
            
            
            
            
            UpdateCommand="UPDATE [Reserva] SET [Fecha_Reserva] = @Fecha_Reserva, [Id_Estado] = @Id_Estado, [Id_Mesa] = @Id_Mesa, [Id_Cliente] = @Id_Cliente, [Cantidad_Comensales] = @Cantidad_Comensales WHERE [Nro_Reserva] = @Nro_Reserva">
            <DeleteParameters>
                <asp:Parameter Name="Nro_Reserva" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="Fecha_Reserva" Type="DateTime" />
                <asp:Parameter Name="Id_Estado" Type="Int32" />
                <asp:Parameter Name="Id_Mesa" Type="Int32" />
                <asp:Parameter Name="Id_Cliente" Type="Int32" />
                <asp:Parameter Name="Cantidad_Comensales" Type="Int32" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="Fecha_Reserva" Type="DateTime" />
                <asp:Parameter Name="Id_Estado" Type="Int32" />
                <asp:Parameter Name="Id_Mesa" Type="Int32" />
                <asp:Parameter Name="Id_Cliente" Type="Int32" />
                <asp:Parameter Name="Cantidad_Comensales" Type="Int32" />
                <asp:Parameter Name="Nro_Reserva" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
    </div>
      <div id="usuleft" Class="contTabla" style="width: 350px;
        float: left;">  
    <table>
    <tr>     <asp:Label ID="Label5" runat="server" Text="Ubicar Cliente:"></asp:Label>
    </tr>
    <tr>
        <td>
            <asp:Label ID="lblCliente" runat="server" Text="Cliente:"></asp:Label>
            <asp:TextBox
                ID="txbReserva" runat="server" Visible="False"></asp:TextBox>
            </td>
            <td>
                <asp:TextBox ID="txbCliente" runat="server" Enabled="False"></asp:TextBox>
            </td>
        </tr>

        <tr>
            <td>
                <asp:Label ID="Label9" runat="server" Text="Ingrese el estado:"></asp:Label>
            </td>
            <td>                
                <asp:DropDownList ID="ddlEstado" runat="server" DataSourceID="Estados" 
                    DataTextField="Descripcion" DataValueField="Id_Estado">
                </asp:DropDownList>
                <asp:SqlDataSource ID="Estados" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:BarCafe %>" 
                    ProviderName="<%$ ConnectionStrings:BarCafe.ProviderName %>" 
                
                    SelectCommand="SELECT Id_Estado, Descripcion FROM [Estado] WHERE ([Clave] = @Clave)
                                    union all
                                    select  0, 'Sin Seleccionar'
                                    order by 1">
                    <SelectParameters>
                        <asp:Parameter DefaultValue="Reservas" Name="Clave" Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>

       
        <tr>
            <td>
                <asp:Label ID="lblMozo" runat="server" Text="Mozo:"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="ddlMozo" runat="server" DataSourceID="Usuarios" 
                    DataTextField="Nombre" DataValueField="Id_Usuario">
                </asp:DropDownList>

                <asp:SqlDataSource ID="Usuarios" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:BarCafe %>" 
                    ProviderName="<%$ ConnectionStrings:BarCafe.ProviderName %>" 
                    SelectCommand="SELECT u.Id_Usuario, 
	   u.Nombre 
FROM Usuario u,
     rol r
where u.Id_Rol = r.Id_Rol
 and r.Descripcion = 'Mozo'
    union all
    select  0, 'Sin Seleccionar'
    order by 1">
                </asp:SqlDataSource>

            </td>
        </tr>       
        
      </table>
    </div>



    <br />
    <br />
    <asp:Button ID="btnAcpetar" runat="server" Text="Aceptar" 
        onclick="btnAcpetar_Click" />
    <asp:Button ID="btnCancelar" runat="server" Text="Cancelar" 
        onclick="btnCancelar_Click" />
        <br/>
    <asp:Label ID="lblError" runat="server" Text="" ForeColor="Red" ></asp:Label>
</asp:Content>
